package com.hup.sb.model;

import com.hup.utils.commons.io.BaseConfig;
import com.hup.utils.swing.model.BaseWindowConfig;
import lombok.Data;

/**
 * @author hugan
 * @date 2022/2/27
 */
@Data
public class MainConfig implements BaseConfig<MainConfig> {

    public static final int MIN_BRIGHTNESS = 20;

    /**
     * 单例程序端口号
     */
    public int appPort = 18328;
    /**
     * 启动时还原亮度,近似于'不保存亮度'
     */
    public boolean resetOnBoot;
    public String desc = "resetOnBoot=true: 启动时还原亮度,近似于'不保存亮度'";

    public BaseWindowConfig windowConfig = new BaseWindowConfig();

    /**
     * 亮度[MIN_BRIGHTNESS,100]
     */
    public int brightness = 70;

    @Override
    public boolean afterLoadFromFileOrReset(MainConfig fileConfig) {
        if (fileConfig == null) return true;
        if (brightness < MIN_BRIGHTNESS || brightness > 100) {
            brightness = MIN_BRIGHTNESS;
            return true;
        }
        return false;
    }

}
